x86: Speed up PV-guest superpage mapping
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 27 May 2010 08:04:46 +0000 (09:04 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 27 May 2010 08:04:46 +0000 (09:04 +0100)
commit06ef473029dcd540b7e4fb76f89cc54fd53a840e
tree249c7b6f44168e2d7ee1d631c892e2130e2df2cb
parent92ed5b7e9c642ff0f7c68eb8a39bd687726ba03c
x86: Speed up PV-guest superpage mapping

The current version of superpage mapping takes a PGT_writable
reference to every page in a superpage each time it is mapped.  This
is extremely slow, so slow that applications become unusable.

My solution for this is to introduce a superpage table in the
hypervisor, similar to the frametable structure for pages.  Currently
this table only has a type_info element.  There are three types a
superpage can have, SGT_mark, SGT_dynamic, or SGT_none.

In normal operation, the first time a superpage is mapped, a
PGT_writable reference is taken to each page in the superpage, and the
superpage is set to type SGT_dynamic and the superpage typecount is
incremented.  On subsequent mappings and unmappings, only the
superpage typecount changes.  On the last unmap, the PGT_writable
reference on each page is removed.

The SGT_mark type is set and cleared through two new MMUEXT
hypercalls, mark_super and unmark_super.  When the hypercall is made,
the superpage's type is set to SGT_mark and a PGT_writable reference
is taken to its pages.  On unmark, the type is cleared and the
reference removed.

If a page is already set to SGT_dynamic when mark_super is called, the
type is changed to SGT_mark and no additional PGT_writable reference
is taken.  If there are still outstanding mappings of this superpage
when unmark_super is called, the type is set to SGT_dynamic and the
PGT_writable reference is not removed.

Fast superpage mapping is only supported on 64 bit hypervisors.  For
32 bit hyperviors, superpage mapping is supported but will be
extremely slow.

Signed-off-by: Dave McCracken <dave.mccracken@oracle.com>
xen/arch/x86/domain.c
xen/arch/x86/mm.c
xen/include/asm-x86/config.h
xen/include/asm-x86/guest_pt.h
xen/include/asm-x86/mm.h
xen/include/asm-x86/page.h
xen/include/asm-x86/x86_32/page.h
xen/include/asm-x86/x86_64/page.h